package com.zjj.lbw.jdk.v7.map;

import java.util.HashMap;
import java.util.Iterator;

/**
 * @author zhanglei.zjj
 * @description HashMap modCont fast-fail机制 快速失败机制测试
 * @date 2023/8/20 16:48
 */
public class ExceptionTest {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        map.put("1", "1");
        map.put("2", "2");

        Iterator<String> iterator = map.keySet().iterator();
        while (iterator.hasNext()) {
            String next = iterator.next();
            if (next.equals("2")) {
//                map.remove(next);
                iterator.remove();
            }
        }
    }
}
